﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.DataDictionaryValueDescription;

namespace ConAppCore
{
    internal class TestDataDictionaryManager
    {
        public static void Test()
        {
            DataDictionaryManager.Registe<FFT点数>();
            TypeDataDictionary dataDictionary = DataDictionaryManager.GetDataDictionary<FFT点数>();

            byte fieldValue = 10;
            int meanValue = 999;
            dataDictionary.Add(fieldValue, meanValue, "FFT999");

            string name1 = dataDictionary.GetFieldValueName(FFT点数.FFT1024);
            string name2 = dataDictionary.GetMeanValueName(1024);
            string name3 = dataDictionary.GetFieldValueName(fieldValue);
            string name4 = dataDictionary.GetMeanValueName(meanValue);

            int meanValue2 = 2888;
            dataDictionary.Update(fieldValue, meanValue2, "FFT2888");
            string name5 = dataDictionary.GetFieldValueName(fieldValue);
            string name6 = dataDictionary.GetMeanValueName(meanValue2);

            int count = (int)dataDictionary.GetMeanValue(FFT点数.FFT1024);
            int code = (byte)dataDictionary.GetFieldValue(1024);
        }

    }

    /// <summary>
    /// FFT点数
    /// </summary>
    [Description("FFT点数")]
    public class FFT点数
    {
        /****************************************************************************
         * 表B.3  FFT点数
         * 代码   含义
         * 1	  128
         * 2	  256
         * 3	  512
         * 4	  1024
         * 5	  4096
         ****************************************************************************/


        /// <summary>
        /// fft128
        /// </summary>
        [DataDictionaryItem("fft128", 128)]
        public const byte FFT128 = 1;

        /// <summary>
        /// fft256
        /// </summary>
        [DataDictionaryItem("fft256", 256)]
        public const byte FFT256 = 2;

        /// <summary>
        /// fft512
        /// </summary>
        [DataDictionaryItem("fft512", 512)]
        public const byte FFT512 = 3;

        /// <summary>
        /// fft1024
        /// </summary>
        [DataDictionaryItem("fft1024", 1024)]
        public const byte FFT1024 = 4;

        /// <summary>
        /// fft4096
        /// </summary>
        [DataDictionaryItem("fft4096", 4096)]
        public const byte FFT4096 = 5;
    }
}
